<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('reimburses', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('project_id')->default(0);
            $table->unsignedBigInteger('user_id')->default(0);
            $table->unsignedBigInteger('role_id')->default(0);
            $table->unsignedBigInteger('source_id')->default(0);
            $table->string('type')->default('reimburse')->comment('类型');
            $table->date('apply_date')->comment('申请日期');
            $table->string('nature')->default('/')->comment('对方性质');
            $table->string('pay_type')->default('/')->comment('支付方式');
            $table->string('receive_type')->default('/')->comment('收款方式');
            $table->decimal('apply_price', 10, 2)->default(0)->comment('申请金额');
            $table->decimal('back_borrow', 10, 2)->default(0)->comment('还借支');
            $table->decimal('audit_price', 10, 2)->default(0)->comment('稽核金额');
            $table->decimal('price', 10, 2)->default(0)->comment('实付金额');
            $table->string('pay_company')->default('/')->comment('支付公司');
            $table->string('bank_charges')->default('/')->comment('手续费');
            $table->string('name')->default('/')->comment('收款昂姓名');
            $table->string('bank')->default('/')->comment('银行');
            $table->string('bank_number')->default('/')->comment('银行账号');
            $table->string('bank_no')->default('/')->comment('银行行号');
            $table->string('remarks')->default('/')->comment('备注');
            $table->timestamps();
        });

        Schema::create('reimburse_details', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('reimburse_id');
            $table->unsignedBigInteger('project_id');
            $table->string('title')->default('/')->comment('费用科目');
            $table->string('type')->default('/')->comment('分摊类型');
            $table->string('project')->default('/')->comment('费用承担项目');
            $table->string('status')->default('/')->comment('项目状态');
            $table->decimal('price', 10, 2)->default(0)->comment('申请金额');
            $table->decimal('audit_price', 10, 2)->default(0)->comment('稽核金额');
            $table->string('role')->default('/')->comment('费用承担部门');
            $table->string('unit')->default('/')->comment('单位');
            $table->integer('nums')->default(1)->comment('数量');
            $table->string('invoice')->nullable()->comment('发票文件');
            $table->string('remarks')->nullable()->default('/');
            $table->integer('tax_rate')->default(0);
            $table->decimal('tax_price', 10, 2)->default(0)->comment('税金');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('reimburse');
        Schema::dropIfExists('reimburse_details');
    }
};
